package com.woniu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.woniu.entity.PageData;
import com.woniu.entity.dto.QueryBerthDTO;
import com.woniu.entity.vo.BerthVo;
import com.woniu.mapper.BerthMapper;
import com.woniu.pojo.Berth;
import com.woniu.pojo.Road;
import com.woniu.service.BerthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import org.springframework.util.StringUtils;

/**
* @author Ma.Lei
* @description 针对表【t_berth】的数据库操作Service实现
* @createDate 2022-12-16 23:27:33
*/
@Service
public class BerthServiceImpl extends ServiceImpl<BerthMapper, Berth>
    implements BerthService {
    @Autowired
    private BerthMapper berthMapper;

    @Override
    public String getIdByCode(String berthCode) {
        return berthMapper.getIdByCode(berthCode);
    }

    @Override
    public void updateBerthStatus(String berthId, String s) {
        berthMapper.updateBerthStatus(berthId,s);
    }

    @Override
    public PageData listSearch(Integer currentPage, Integer pageSize, QueryBerthDTO queryBerthDTO) {
        // 2. 构建分页参数
        IPage<BerthVo> page = new Page<>(currentPage, pageSize);
        // 3. roadMapper
        IPage<BerthVo> berthVoIPage = berthMapper.selectPageberth(page,queryBerthDTO);
        // 4. 组装返回数据对象
        PageData pageData = new PageData(berthVoIPage.getTotal(), berthVoIPage.getRecords());
        // 5. 返回数据
        return pageData;
    }

    @Override
    public Road getByRoadName(String id) {
        return berthMapper.getByRoadName(id);
    }
    public Berth selectByBerthCode(String berthCode) {
        return berthMapper.selectByBerthCode(berthCode);
    }

    @Override
    public Road selectRoadByBerthCode(String berthCode) {
        return berthMapper.selectRoadByBerthCode(berthCode);
    }

    @Override
    public void updateStatusById(String id, String status) {
        berthMapper.updateStatusById(id,status);
    }
}




